<%@ page import="yanglei.day0109.lottery.dao.UserDao" %>
<%@ page import="yanglei.day0109.lottery.dao.impl.UserDaoImpl" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="yanglei.day0109.lottery.po.User" %>
<%@ page import="yanglei.day0109.lottery.constants.UserStatus" %><%--
  Created by IntelliJ IDEA.
  User: 杨雷
  Date: 2023/1/9
  Time: 11:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>燃油汽车指标摇号系统</title>
    <!-- 引用外部css样式文件 -->
    <link rel="stylesheet" href="../../../css/yanglei/day0109/index.css">
    <%--
      <script type="text/javascript" src="../../../js/yanglei/day0109/jquery-3.6.3.js"></script>
    --%>
    <%--
      <script type="text/javascript" src="../../../js/yanglei/day0109/addUser.js"></script>
    --%>

    <%
        /* jsp组成部分：jsp小脚本 内置对象（9个内置对象） jsp指定  注释 */
        /* 在jsp页面中获取后端Java程序，进行数据交互 */
        // 使用多态体现，实例化 UserDao userDao
        UserDao userDao = new UserDaoImpl();
        // 创建Map集合对象,用来存储查询列表的搜索条件参数
        Map<String, Object> map = new HashMap<>();
        // 调用查询数据列表方法
    /*List<User> userList = userDao.queryUserByType(map);
    for (int i = 0; i < userList.size(); i++){
      out.println(userList.get(i).getMarkNo());
    }*/
        // 获取indexController.jsp中存储在request作用域中的 searchName
        String searchName = request.getAttribute("searchName") == null ? "" :
                String.valueOf(request.getAttribute("searchName"));
        if (!"".equals(searchName)) {
            map.put("markNo", searchName);
        }
        // 调用查询列表方法
        List<User> userList = userDao.queryUserByType(map);
    %>
</head>
<body>
<div id="container">
    <header>
        <h2>燃油汽车指标摇号系统</h2>
    </header>
    <div id="main_body">
        <!-- <aside></aside> 侧边栏-->
        <div id="aside">
            <a href="index.jsp">参与摇号用户</a>
            <a href="lottery.html">摇号</a>
        </div>
        <div id="main_center">
            <!-- 列表展示 -->
            <form method="post" action="indexController.jsp">
                <div id="search">
                    <button name="btnSeach" id="ch"><a href="addUser.jsp">添加</a></button>
                    <!-- 搜索表单 -->
                    <form id="example">
                        <input type="text" placeholder="中签编码" name="search">
                    </form>
                    <button name="btnSeach" id="sous">搜索</button>
                </div>
                <table>
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>中签编码</th>
                        <th>持照状态</th>
                        <th>手机号码</th>
                        <th>开户日期</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <%
                        for (int i = 0; i < userList.size(); i++) {
                    %>
                    <tr>
                        <td><%=userList.get(i).getUserName()%>
                        </td>
                        <td><%=userList.get(i).getMarkNo()%>
                        </td>
                        <td><%=UserStatus.getUserStatusByCode(userList.get(i).getStatus()).getValue()%>
                        </td>
                        <td><%=userList.get(i).getPhone()%>
                        </td>
                        <td><%=userList.get(i).getOpenDate()%>
                        </td>
                        <td><a href="#">详情</a>&nbsp;<a href="#">删除</a></td>
                    </tr>
                    <%
                        }
                    %>

                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
</body>
</html>
